/**
 * author: Maxim Dybarskiy
 * date:   May 16, 2011
 * time:   3:41:27 PM
 */
package com.hotel.main.service;

import com.hotel.main.entity.*;
import com.hotel.main.entity.enums.*;
import com.hotel.main.service.dao.CustomHibernateDaoSupport;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class AccommodationService extends CustomHibernateDaoSupport implements IAccommodationService {
     
    @Override
    @Transactional
    public List<Room> findRoom(RoomClass roomClass, Byte floor, RoomQuantity roomQuantity) {
        return getHibernateTemplate().findByNamedQuery(Room.NQ_FIND_BY_PARAMETERS_CLASS_FLOOR_QUANTITY, new Object[]{roomClass, floor, roomQuantity.getQuantity()});
    }
    
    @Override
    @Transactional
    public List<Room> findRoom(RoomClass roomClass, RoomQuantity roomQuantity) {
        return getHibernateTemplate().findByNamedQuery(Room.NQ_FIND_BY_PARAMETERS_CLASS_QUANTITY, new Object[]{roomClass, roomQuantity.getQuantity()});
    }
    
    @Override
    @Transactional
    public List<Room> findRoom(RoomClass roomClass, Byte floor) {
        return getHibernateTemplate().findByNamedQuery(Room.NQ_FIND_BY_PARAMETERS_CLASS_FLOOR, new Object[]{roomClass, floor});
    }
    
    @Override
    @Transactional
    public List<Room> findRoom(RoomClass roomClass) {
        return getHibernateTemplate().findByNamedQuery(Room.NQ_FIND_BY_PARAMETERS_CLASS, roomClass);
    }

    @Override
    @Transactional
    public List<Room> findAll() {
        return getHibernateTemplate().findByNamedQuery(Room.NQ_FIND_ALL);
    }
}
